package com.hanhan.chargingpile.stations.controller.admin;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hanhan.chargingpile.stations.pojo.entity.ChargingPile;
import com.hanhan.chargingpile.stations.pojo.vo.ChargingPileVO;
import com.hanhan.chargingpile.stations.service.ChargingPileService;
import com.hanhan.common.result.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.ibatis.jdbc.Null;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 充电桩 前端控制器
 * </p>
 *
 * @author HanHan
 * @since 2023-03-22
 */
@Api(tags = "充电桩管理")
@RestController
@RequestMapping("/admin/stations/chargingPile")
public class ChargingPileController {

    @Resource
    private ChargingPileService chargingPileService;

    @ApiOperation("获取充电桩分页列表")
    @GetMapping("/list/{page}/{limit}")
    public R listPage(
            @ApiParam(value = "当前页码", required = true)
            @PathVariable Integer page,

            @ApiParam(value = "每页记录数", required = true)
            @PathVariable Integer limit,

            @ApiParam(value = "站点ID")
            @RequestParam(required = false) Long chargingStationsId,
            @ApiParam(value = "编号")
            @RequestParam(required = false) String serialNumber,
            @ApiParam(value = "型号")
            @RequestParam(required = false) String chargingPileSpec,
            @ApiParam(value = "电流类型")
            @RequestParam(required = false) Integer acDc,
            @ApiParam(value = "使用状态", defaultValue = "")
            @RequestParam(required = false) boolean useStatus,
            @ApiParam(value = "在线状态", defaultValue = "")
            @RequestParam(required = false) boolean offLineIs) {
        ChargingPile chargingPile = new ChargingPile();
        chargingPile.setChargingStationsId(chargingStationsId);
        chargingPile.setSerialNumber(serialNumber);
        chargingPile.setChargingPileSpec(chargingPileSpec);
        chargingPile.setAcDc(acDc);
        chargingPile.setUseStatus(useStatus);
        chargingPile.setOffLineIs(offLineIs);
        Page<ChargingPile> pageParam = new Page<>(page, limit);
        IPage<ChargingPileVO> pageModel = chargingPileService.selectChargingPileList(pageParam, chargingPile);
        return R.ok().data("pageModel",pageModel);
    }

}

